<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

require_once 'config.php';

use Lib\Msg;
use Lib\Comment;

$m = new Msg($db, 'bbq');
$c = new Comment($db, 'bbq_comment');

$ano = $m->GetMsg(1);
$msgSum = $m->GetMsgCount();
$page = 1;
$page_max = ceil($msgSum / 5);

if ($page >= $page_max) {
    $page = $page_max;
} else if ($page <= 0) {
    $page = 1;
}

$page_p = $page - 1;
$page_n = $page + 1;


foreach ($ano as $cid) {
    $id = $cid['id'];
    $comment_num[$cid['id']] = $c->GetCommentNum( $id );
}

//Now set some var

$SiteUrl = 'http://' . $SiteHost . '/' . $SiteDir;
$css_url = $SiteUrl . '/views/css';
$image_url = $SiteUrl . '/views/image';
$viewUrl = 'http://' . $SiteHost . '/' . $SiteDir . '/views';

require 'views/indexV.php';
